﻿using FizzBuzzGenerator;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace FizzBuzzTests
{
    /// <summary>
    ///This is a test class for FizzBuzzConsoleWriterTest and is intended
    ///to contain all FizzBuzzConsoleWriterTest Unit Tests
    ///</summary>
    [TestClass()]
    public class TokenConsoleWriterTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        /// <summary>
        ///A test for default tokens (Fizz, Buzz) by providing start and end values. 
        ///</summary>
        [TestMethod()]
        public void TestDefaultTokensWithStartAndEnd()
        {
            TokenConsoleWriter target = new TokenConsoleWriter(1, 15);
            List<string> expected = new List<string> { "", "", "Fizz", "", "Buzz", "Fizz", "", "", "Fizz", "Buzz", "", "Fizz", "", "", "FizzBuzz" };
            
            List<string> actual;
            actual = target.GetTokens();
            
            for(int i=0;i<expected.Count;i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
            
        }

        /// <summary>
        ///A test for custom tokens with start and end values. 
        ///</summary>
        [TestMethod()]
        public void TestForCustomTokensWithStartAndEnd()
        {
            TokenConsoleWriter target = new TokenConsoleWriter(1, 15,"DivBy3", "DivBy5", "DivBy5And3","NotDivisible");
            List<string> expected = new List<string> { "NotDivisible", "NotDivisible", "DivBy3", "NotDivisible", "DivBy5", "DivBy3", 
                                                        "NotDivisible", "NotDivisible", "DivBy3", "DivBy5", "NotDivisible", "DivBy3", "NotDivisible", "NotDivisible", "DivBy5And3" };

            List<string> actual;
            actual = target.GetTokens();

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }

        }

        /// <summary>
        ///A test for default tokens without start and end. 
        ///</summary>
        [TestMethod()]
        public void TestDefaultTokens()
        {
            TokenConsoleWriter target = new TokenConsoleWriter();
            List<string> expected = new List<string> { "Fizz", "","", "", "", "", "Fizz", "", "Buzz", "Fizz", 
                                                        "", "", "Fizz", "Buzz", "", "Fizz", "", "", "FizzBuzz" };

            List<string> actual;
            actual = target.GetTokens();

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
    }
}
